package com.jade.yh.zsy.mobile.wechat.api;

import com.jade.bss.base.RoleAction;
import com.jade.framework.base.context.ApplicationContextUtils;
import com.jade.framework.base.util.PagingResult;
import com.jade.framework.base.util.ResponseUtils;
import com.jade.store.wechat.service.WechatMsgFacade;
import com.jade.store.wechat.vo.WechatMsgVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;

/**
 * 微信消息管理
 * User: JinYa 2009_jinya@163.com
 * Date: 2016-6-15
 * Time: 15:20
 * Version : 1.0
 * Remark:
 * History:
 */
@RestController
@RequestMapping(value = "/wxmsg", produces = MediaType.APPLICATION_JSON_VALUE)
@Api(value = "微信消息", description = "微信模块--微信消息")
public class WxMsgController {
    private WechatMsgFacade wechatMsgFacade = ApplicationContextUtils.getBean("WechatMsgFacade");

    @RequestMapping(value =  RoleAction.QUERY, method = RequestMethod.GET)
    @ApiOperation(value = "我的会员微信消息", httpMethod = "GET", response = WechatMsgVo.class)
    public void QUERY(@ApiParam(value = "起始值") @RequestParam(value = "offset", defaultValue = "0") int offset,
                      @ApiParam(value = "每页大小") @RequestParam(value = "length", defaultValue = "10") int length,
                      @ApiParam(value = "关键词") @RequestParam (value = "keyword", required = false) String keyword,
                      @ApiParam(value = "排序字段") @RequestParam(value = "sort", required = false) String sort,
                      @ApiParam(value = "排序规则", allowableValues = "desc, asc") @RequestParam(value = "order", required = false) String order,
                      HttpServletResponse response, WechatMsgVo entityVo) throws Exception {
        PagingResult result = wechatMsgFacade.queryEntity(entityVo, offset, length, keyword, sort);
        ResponseUtils.writeSuccessPagingResult(response, result);
    }

}
